package webs.servlet.ServletDemoTwo;
//doPost()和doGet()获取参数信息的通用方式

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/demo6")
public class servletTest_Six extends HttpServlet
{
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
        //post获取参数
        String name=req.getParameter("name");
        String password=req.getParameter("password");
        System.out.println("name"+"-----"+name);
        System.out.println("passwors"+"----"+password);
        String[] hobbies=req.getParameterValues("hobby");
        for(String hobby:hobbies)
            System.out.println(hobby);
    }
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
        this.doPost(req,resp);
    }
}
